package com.ibm.datamodel.exp;

import java.io.Serializable;

/*
 * this package is a experiment package
 * we compare the parseddatamessage's component
 * It turns out that using object array is better.
 */
public class CompareMessage implements Serializable{

	Comparable[] values;

	public Comparable[] getValues() {
		return values;
	}

	public void setValues(Comparable[] values) {
		this.values = values;
	}
	
	public CompareMessage(Double[][] tmp,int[] die,boolean fix) {
		if (fix) {
			// don't need header
			int sum = 0;
			for (int i = 0; i < die.length; i++) {
				sum += die[i];
			}
			values = new Comparable[sum];
			int index = 0;
			for (int i = 0; i < die.length; i++) {
				for (int j = 0; j < die[i]; j++) {
					values[index] = tmp[i][j];
					index++;
				}
			} 
		}else {
			// need header when len > 1
			int sum = 0;
			for (int i = 0; i < die.length; i++) {
				sum += die[i];
				if (die[i] > 1) {
					sum += 1;
				}
			}
			values = new Comparable[sum];
			int index = 0;
			for (int i = 0; i < die.length; i++) {
				if (die[i] > 1) {
					values[index] = die[i];
					index ++;
				}
				for (int j = 0; j < die[i]; j++) {
					values[index] = tmp[i][j];
					index++;
				}
			} 
		}
	}
	
}
